package com.lfnyxy.common.dto;

/**
 * Created by ted on 18/2/22.
 */
public class CodeMessage {
    private long code;
    private String message;

    //public static CodeMessage SUCCESS = new CodeMessage(0, "success");
    public static CodeMessage SAVE_FAILED = new CodeMessage(500100, "保存数据失败");
    public static CodeMessage GET_ITEM_FAILED = new CodeMessage(500200, "获取数据异常");
    public static CodeMessage DELETE_ITEM_FAILED = new CodeMessage(500300, "删除数据异常");
    public static CodeMessage QUERY_LIST_FAILED = new CodeMessage(500400, "获取所有数据异常");
    public static CodeMessage QUERY_PARAM_ERROR = new CodeMessage(500500, "请求参数异常");



    public static CodeMessage USER_DUPLICATION = new CodeMessage(100100, "创建的用户名已经存在");

    public static CodeMessage LOGIN_CODE_EXPIRE = new CodeMessage(300100, "验证码已过期");
    public static CodeMessage LOGIN_CODE_ERROR = new CodeMessage(300101, "验证码错误");
    public static CodeMessage LOGIN_PASSWORD_ERROR = new CodeMessage(300102, "密码错误,请重新输入");
    public static CodeMessage LOGIN_ERROR = new CodeMessage(300102, "用户名,密码错误,请重新输入");

    private CodeMessage(long code, String message) {
        this.code = code;
        this.message = message;
    }

    public CodeMessage fillArgs(Object... args){
        long code  = this.code;
        String msg = String.format(this.message, args);
        return new CodeMessage(code, msg);
    }

    public long getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
